package Marco::Object;

use 5.006000;
use strict;
use warnings;
use Log::Log4perl qw();
use base 'Class::Accessor';
__PACKAGE__->mk_ro_accessors( qw( logger class_logger ) );

use version 0.74;
our $VERSION = version->new(qw$Revision: 12 $);

=pod
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

Marco::Object - A really nifty base class

=head1 SYNOPSIS

  use Marco::Object;
  blah blah blah

=head1 DESCRIPTION

Stub documentation for Marco::Object, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head1 METHODS

=over 5

=item Marco::Object-E<gt>new({});

Create a new instance of this class

	my $object = Your::Class->new({something=E<gt>;'here'});
 
	$object->do_stuff("HI!");
	
You do not need to inherit new.  If you need to do magic, extend Your::Class->init

=cut
sub new {
    my($proto, $fields) = @_;
    my($class) = ref $proto || $proto;

    $fields = {} unless defined $fields;

    # make a copy of $fields.
    my $self = bless {%$fields}, $class;
    $self->{logger} = Log::Log4perl::get_logger($class) unless defined $self->{logger};
	
	# this is a way to log class specific stuff seperatly
	$self->{class_logger} = Log::Log4perl::get_logger("Logger::Class::".$class) unless defined $self->{class_logger};
	
	$self->class_logger->debug("Gave birth to a new '$class'");
	
	# initalize ourself
	$self->init();
	return $self;
}

=pod
=item Marco::Object-E<gt>init({});

Put your module initilization code here.  Make sure to call your base class.

	.... your module ....
	sub init {
		my $self=shift;
		
		# call the superclass
		$self->SUPER::init(@_);

		# do your junk here
		
		# return our stuff
		return $self;
	}

=cut
sub init {
  my $self=shift;
  $self->logger->trace("All the way at the base class, baby", @_) if $_[0];
  return $self;
}

sub DESTROY {
	my $self = shift;
	$self->class_logger->debug("killing ourself",$self);
	$self->SUPER::DESTROY if $self->can("SUPER::DESTROY");
	undef $self;
}

=pod
=back
=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

Cory R. King, E<lt>coryking@mozimedia.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2009 by Mozi Media Group, LLC.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.9 or,
at your option, any later version of Perl 5 you may have available.


=cut


1;
__END__

